Security News
npm Updates Search Experience with New Objective Sorting Options
npm has a revamped search experience with new, more transparent sorting options—Relevance, Downloads, Dependents, and Publish Date.
@codemirror/autocomplete
Advanced tools
The @codemirror/autocomplete package is a module for the CodeMirror code editor that provides autocompletion functionality. It can be used to suggest, complete, or hint at possible code snippets, variables, or other elements to users as they type, enhancing the coding experience by making it faster and reducing errors.
Autocompletion
Enables autocompletion in the CodeMirror editor. As the user types, suggestions are displayed in a dropdown, allowing for quick insertion of code snippets.
import { autocompletion } from '@codemirror/autocomplete';
// To enable autocompletion in a CodeMirror editor
new EditorView({
extensions: [autocompletion()],
parent: document.body
});
Customizable Completion Source
Allows developers to provide a custom source for completions, enabling the suggestion of context-specific code snippets or keywords.
import { autocompletion, CompletionSource } from '@codemirror/autocomplete';
const myCompletionSource: CompletionSource = (context) => {
// Custom logic to provide completions
return [{ label: 'mySnippet', type: 'keyword' }];
};
// To use the custom completion source
new EditorView({
extensions: [autocompletion({ override: [myCompletionSource] })],
parent: document.body
});
Asynchronous Completion
Supports asynchronous computation of completions, allowing for the integration of dynamic data sources or external APIs for suggestions.
import { autocompletion, CompletionResult } from '@codemirror/autocomplete';
const asyncCompletionSource = async (context): Promise<CompletionResult> => {
// Fetch or compute completions asynchronously
return { from: context.pos, options: [{ label: 'asyncSnippet', type: 'function' }] };
};
// To use asynchronous completions
new EditorView({
extensions: [autocompletion({ override: [asyncCompletionSource] })],
parent: document.body
});
The Monaco Editor is the code editor that powers VS Code, which comes with built-in autocompletion features. It is a full-featured editor with a rich API for customization, including autocompletion, but it is a standalone editor rather than a plugin.
A jQuery plugin for autocompletion. Unlike @codemirror/autocomplete, which is designed for code editors, jquery-textcomplete is more general-purpose and can be used for any text input field.
[ WEBSITE | DOCS | ISSUES | FORUM | CHANGELOG ]
This package implements autocompletion for the CodeMirror code editor.
The project page has more information, a number of examples and the documentation.
This code is released under an MIT license.
We aim to be an inclusive, welcoming community. To make that explicit, we have a code of conduct that applies to communication around the project.
6.18.3 (2024-11-13)
Backspacing to the start of the completed range will no longer close the completion tooltip when it was triggered implicitly by typing the character before that range.
FAQs
Autocompletion for the CodeMirror code editor
The npm package @codemirror/autocomplete receives a total of 825,236 weekly downloads. As such, @codemirror/autocomplete popularity was classified as popular.
We found that @codemirror/autocomplete demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
npm has a revamped search experience with new, more transparent sorting options—Relevance, Downloads, Dependents, and Publish Date.
Security News
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.